/**
 * @returns {[活性, 平衡度, 稳定性, 抗压能力, 疲劳程度]}
 */
export function calculateAnxiousScores(sdnn, tp, lf, hf) {
  if (sdnn < 80 && sdnn > 40) {
    sdnn = sdnn - 40 + 60
  } else if (sdnn <= 40) {
    sdnn = 60
  } else {
    sdnn = 100
  }
  if (tp > 1800 && tp <= 2000) {
    tp = (tp - 1800) / 8 + 60
  } else if (tp > 2000 && tp <= 2800) {
    tp = (tp - 2000) / 32 + 75
  } else if (tp <= 1800) {
    tp = 60
  } else {
    tp = 100
  }
  if (lf > 370 && lf < 850) {
    lf = (lf - 550) / 12 + 75
  } else if (lf <= 370) {
    lf = 60
  } else {
    lf = 100
  }
  if (hf > 360 && hf <= 450) {
    hf = (hf - 450) / 6 + 75
  } else if (hf > 450 && hf < 750) {
    hf = (hf - 450) / 12 + 75
  } else if (hf < 360) {
    hf = 60
  } else {
    hf = 100
  }
  let lf_hf = lf / hf
  if (lf_hf > 0.5 && lf_hf < 1.7) {
    lf_hf = -33.3 * (lf_hf - 1.25) + 75
  } else if (lf_hf >= 1.7) {
    lf_hf = 60
  } else {
    lf_hf = 100
  }
  //活性
  let huoxin = sdnn * 0.5 + tp * 0.5
  //平衡度
  let pinghengdu = lf_hf
  //稳定性
  let weidingxing = lf * 0.5 + hf * 0.5
  //抗压能力
  let kangyanengli = sdnn
  //疲劳程度
  let pilaochengdu = 100 - (tp * 0.4 + lf * 0.4 + lf_hf * 0.2)
  let info = {
    activity: Math.round(huoxin),
    degreeBalance: Math.round(pinghengdu),
    stability: Math.round(weidingxing),
    degreeResistance: Math.round(kangyanengli),
    degreetired: Math.round(pilaochengdu),
  }
  return info
}